package com.bbx.taxi.client.Activity.Menu;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import butterknife.Bind;

import com.bbx.taxi.client.R;
import com.bbx.taxi.client.Activity.Base.BaseBBXActivity;

public class EditNameActivity extends BaseBBXActivity implements TextWatcher,
		OnClickListener {
	@Bind(R.id.et_name)
	EditText et_name;
	@Bind(R.id.iv_delete)
	ImageView iv_delete;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.activity_editname);
		super.onCreate(savedInstanceState);
		
	}

	@Override
	protected void initView() {
		setTitle(true,getString(R.string.title_eidt_name), -1, getString(R.string.title_right_save));
		et_name.addTextChangedListener(this);
		et_name.setText(getIntent().getExtras().getString("user_name"));

	}

	@Override
	protected void initData() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void desotryItems() {
		// TODO Auto-generated method stub

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.tv_right://保存
			Bundle bundle = new Bundle();
			bundle.putString("user_name",et_name.getText().toString());
			Intent intent = new Intent();
			intent.putExtras(bundle);
			setResult(resultCode, intent);
			finish();
			break;
		case R.id.iv_delete:
			et_name.setText("");
			break;
		default:
			super.onClick(v);
			break;
		}
		super.onClick(v);
	}

	@Override
	public void afterTextChanged(Editable s) {
		if (!s.toString().isEmpty()) {
			iv_delete.setVisibility(View.VISIBLE);
		} else {
			iv_delete.setVisibility(View.GONE);
		}

	}

	@Override
	public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
			int arg3) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
		// TODO Auto-generated method stub

	}
}
